from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.firefox.service import Service

driver = webdriver.Firefox(
    service=Service(
        executable_path=r"..\data\geckodriver_v0.35.0_win64.exe",
    )
)


driver.get("http://36.139.193.99:8280/mvue/login")
print(driver.title)
print(driver.current_url)

driver.implicitly_wait(10)
driver.find_elements(
    By.XPATH, '//*[@class="el-input__inner"]')[0].send_keys("ciallo")
driver.find_elements(
    By.XPATH, '//*[@class="el-input__inner"]')[1].send_keys("123456")
driver.find_element(
    By.XPATH, "//*[contains(@class,'el-button el-button--primary el-button--medium')]"
).click()
driver.implicitly_wait(30)

# driver.close()

# driver.quit()
# choice = input("Do you want to close the browser? (Y/N) ")
# if choice.lower() == "y":
#     # 关闭浏览器
#     driver.quit()
# else:
#     print("Browser will remain open.")
result = driver.execute_script(
    "return confirm('Do you want to close the browser?');")

if result:
    print("用户点击了确定")
    driver.quit()
else:
    print("用户点击了取消")
